package com.base;

/**
 * @author: sun.hongliang
 * @create: 2019/04/12 11:12
 */
public class HashCodeTest {
    public static void main(String[] args) {

        String a = new String("hhh");
        String b = new String("hhh");

        //内存地址hash 不会关心是否重写hashCode
        System.out.println(System.identityHashCode(a));
        System.out.println(System.identityHashCode(b));
        System.out.println(a.hashCode());
        System.out.println(b.hashCode());

        System.out.println("==========");

        MyIterator myIterator1 = new MyIterator("a");
        MyIterator myIterator2 = new MyIterator("a");

        System.out.println(System.identityHashCode(myIterator1));
        System.out.println(System.identityHashCode(myIterator2));
        System.out.println(myIterator1.hashCode());
        System.out.println(myIterator2.hashCode());
    }
}
